<template>
	<view>
		<c-base-page :navText="'请假详情'">
			<uni-list>
				<uni-list-item title="标题" :rightText="vacateItem.title"></uni-list-item>
				<uni-list-item title="请假类型" :rightText="vacateItem.typeDesc"></uni-list-item>
				<uni-list-item title="开始时间" :rightText="vacateItem.beginTime"></uni-list-item>
				<uni-list-item title="结束时间" :rightText="vacateItem.endTime"></uni-list-item>
				<uni-list-item title="请假时长" :rightText="vacateItem.askDur"></uni-list-item>
				<uni-list-item title="留校状态" :rightText="vacateItem.schoolDesc"></uni-list-item>
				<uni-list-item title="请假原因" :rightText="vacateItem.description"></uni-list-item>
				<uni-list-item title="父母姓名" :rightText="vacateItem.parentName"></uni-list-item>
				<uni-list-item title="父母电话" :rightText="vacateItem.parentPhoneNumber"></uni-list-item>
				<uni-list-item title="请假去向" :rightText="vacateItem.whereaboutDesc"></uni-list-item>
				<uni-list-item title="请假状态" :rightText="vacateItem.statusDesc"></uni-list-item>
				<uni-list-item title="审核教师" :rightText="公假"></uni-list-item>
				<uni-list-item title="审核时间" :rightText="公假"></uni-list-item>
				<uni-list-item title="教师批注" :rightText="公假"></uni-list-item>
				<uni-list-item title="请假图片" :rightText="公假"></uni-list-item>
				<uni-list-item title="请假图片" :rightText="公假"></uni-list-item>
				<uni-list-item title="请假图片" :rightText="公假"></uni-list-item>
				<uni-list-item title="请假图片" :rightText="公假"></uni-list-item>
				<uni-list-item title="请假图片" :rightText="公假"></uni-list-item>
			</uni-list>
		</c-base-page>
	</view>
</template>

<script>
	export default {
		name: "pageStudentVacateDetail",
		data() {
			return {
				vacateId: null,
				vacateItem: {}
			}
		},
		async onLoad(e) {
			await this.$onLaunched
			this.vacateId = e && e.id ? Number(e.id) : ""
			this.getDataDetail()
		},
		methods: {
			getDataDetail() {
				this.httpGet({
					url: this.$apis.apiAskLeaveDetail + "?id=" + this.vacateId
				}).then(res => {
					this.vacateItem = res.result
					let leaveItem = this.typeActions.find(x => {
						return x.value === this.vacateItem.isLeaveSchool
					})
					this.vacateItem.schoolDesc = leaveItem && leaveItem.name || ""
					this.vacateItem.images = this.vacateItem.images || []
					this.statusDesc = this.tranceStatusDesc(this.vacateItem)
					// 判断是否有权限显示审核
					this.vacateItem.approvalApply = this.vacateItem.approvalApplys.find(m => {
						return m.isRelative && m.approvalStatus === 0
					})
					this.vacateItem.hasApproval = this.vacateItem.approvalApply 
						&& this.vacateItem.approvalApply == this.vacateItem.approvalApplys.find(m => m.approvalStatus == 0)
					console.log(this.vacateItem.hasApproval)
					this.vacateItem.askDur = this.mxTranceTimeToDay(this.vacateItem)
				})
			},
			tranceStatusDesc(item) {
				let desc = ""
				if (this.$enums && this.$enums.AskLeaveStatus) {
					desc = this.$enums.AskLeaveStatus.find(x => {
						return x.value == item.status
					}).desc || ""
				}
				return desc
			},
		}
	}
</script>

<style scoped lang="scss">

</style>
